#!/bin/bash

HADOOP_HOME=/www/hadoop2
HADOOP_BIN=$HADOOP_HOME/bin/hadoop
HADOOP_LOGS=$HADOOP_HOME/jobs/logs

email="$1"
shift
ARGS=$@

#nohup ls $ARGS >> $HADOOP_LOGS/hadoop_jobs.log 2>&1 &
$HADOOP_BIN jar $ARGS > $HADOOP_LOGS/hadoop_jobs.log.tmp 2>&1 &
wait

echo >> $HADOOP_LOGS/hadoop_jobs.log
echo "$email ------ $HADOOP_BIN jar $ARGS" >> $HADOOP_LOGS/hadoop_jobs.log
cat $HADOOP_LOGS/hadoop_jobs.log.tmp >> $HADOOP_LOGS/hadoop_jobs.log

$HADOOP_HOME/jobs/bin/mail.py $email $HADOOP_LOGS/hadoop_jobs.log.tmp > /dev/null 2>&1

rm -f $HADOOP_LOGS/hadoop_jobs.log.tmp
